﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using User.Model;

namespace User.Data
{
    public class UserContext : ObjectContext
    {
        public UserContext()
            : base("name=UserEntities",
                "UserEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            this.ContextOptions.ProxyCreationEnabled = true;

            users = CreateObjectSet<Model.User>();
            roles = CreateObjectSet<Role>();
            resources = CreateObjectSet<Resource>();
            actions = CreateObjectSet<Model.Action>();
            userRoles = CreateObjectSet<UserRole>();
            permissions = CreateObjectSet<Permission>();
        }

        public ObjectSet<Model.User> Users
        {
            get
            {
                return users;
            }
        }
        private ObjectSet<Model.User> users;

        public ObjectSet<Role> Roles
        {
            get
            {
                return roles;
            }
        }
        private ObjectSet<Role> roles;

        public ObjectSet<Resource> Resources
        {
            get
            {
                return resources;
            }
        }
        private ObjectSet<Resource> resources;

        public ObjectSet<Model.Action> Actions
        {
            get
            {
                return actions;
            }
        }
        private ObjectSet<Model.Action> actions;

        public ObjectSet<UserRole> UserRoles
        {
            get
            {
                return userRoles;
            }
        }
        private ObjectSet<UserRole> userRoles;

        public ObjectSet<Permission> Permissions
        {
            get
            {
                return permissions;
            }
        }
        private ObjectSet<Permission> permissions;
    }
    
}
